<?php

    function a ($var) {
        header('Content-Type: text/css; charset=utf-8');
        print_r($var);
        die();
    }

    function alert ($msg = '') {
        die(strval($msg));
    }



    /* Common FN */
    function check_is_https() {
        if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER['HTTPS']) != 'off') {
            return true;
        } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
            return true;
        } elseif (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) != 'off') {
            return true;
        } else {
            return false;
        }
    }
    
    function get_url_protocol_and_host() {
        $p = check_is_https() ? 'https://' : 'http://';
        return $p . $_SERVER['HTTP_HOST'] . '/';
    }


    // 获取随机字符串 - 6位
    function special_get_rand_string () {
        $res = '';
        
        // $chars = 'ABCDEFGHJKLMNPRTUVWXYZabcdefghjkmnpqrtuvwxyz0123456789';
        $chars = 'abcdefghjkmnpqrtuvwxyz0123456789';
        
        $length = strlen($chars);
        $max_length = 6;

        for ($i = 0;$i<$max_length; $i++) {
            $randIndex = rand(0, $length - 1);
            $res .= $chars[ $randIndex ];
        }

        return $res;
    }

